import sys
from collections import Counter
count = 0
lst_input = []
for line in sys.stdin:
if count == 0:
count = 1
continue
lst_input.append(line)
lst = []
for i in range(0, len(lst_input), 3):
lst.append(lst_input[i:i+3])
def two_array(a, b):
a = Counter(a)
b = Counter(b)
for k in sorted(b.keys()):
while b[k]:
if a[k-1] > 0:
a[k-1] -= 1
b[k] -= 1
elif a[k] > 0:
a[k] -= 1
b[k] -=1
else:
return False
return True
for i in lst:
a = i[1]
b = i[2]
a = list(map(int, a.split()))
b = list(map(int, b.split()))
a = Counter(a)
b = Counter(b)
res = two_array(a, b)
if res:
print("YES")
else:
print("NO")
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int a[105],b[105];
int main() {
int T = 1, kase = 0;
cin >> T;
while (T--) {
int n,fl=1;
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++) scanf("%d",&b[i]);
sort(a+1,a+n+1),sort(b+1,b+n+1);
for(int i=1;i<=n;i++) if(b[i]-a[i]!=1&&b[i]-a[i]!=0) fl=0;
puts(fl?"YES":"NO");
}
return 0;
}
1475A - Odd Divisor | 1454B - Unique Bid Auction |
978C - Letters | 501B - Misha and Changing Handles |
1496A - Split it | 1666L - Labyrinth |
1294B - Collecting Packages | 1642B - Power Walking |
1424M - Ancient Language | 600C - Make Palindrome |
1669D - Colorful Stamp | 1669B - Triple |
1669A - Division | 1669H - Maximal AND |
1669E - 2-Letter Strings | 483A - Counterexample |
3C - Tic-tac-toe | 1669F - Eating Candies |
1323B - Count Subrectangles | 991C - Candies |
1463A - Dungeon | 1671D - Insert a Progression |
1671A - String Building | 1671B - Consecutive Points Segment |
1671C - Dolce Vita | 1669G - Fall Down |
4D - Mysterious Present | 1316B - String Modification |
1204A - BowWow and the Timetable | 508B - Anton and currency you all know |